package cn.iocoder.yudao.module.biz.dal.mysql.licenceSafeMeasures;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.biz.controller.admin.licenceSafeMeasures.vo.BizLicenceSafeMeasuresExportReqVO;
import cn.iocoder.yudao.module.biz.controller.admin.licenceSafeMeasures.vo.BizLicenceSafeMeasuresPageReqVO;
import cn.iocoder.yudao.module.biz.dal.dataobject.licenceSafeMeasures.BizLicenceSafeMeasuresDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 危险作业票安全措施 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BizLicenceSafeMeasuresMapper extends BaseMapperX<BizLicenceSafeMeasuresDO> {

    default PageResult<BizLicenceSafeMeasuresDO> selectPage(BizLicenceSafeMeasuresPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BizLicenceSafeMeasuresDO>()
                .eqIfPresent(BizLicenceSafeMeasuresDO::getLicenceId, reqVO.getLicenceId())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getType, reqVO.getType())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getContent, reqVO.getContent())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getQualified, reqVO.getQualified())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getApplicable, reqVO.getApplicable())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getPhoto, reqVO.getPhoto())
                .betweenIfPresent(BizLicenceSafeMeasuresDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(BizLicenceSafeMeasuresDO::getId));
    }

    default List<BizLicenceSafeMeasuresDO> selectList(BizLicenceSafeMeasuresExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BizLicenceSafeMeasuresDO>()
                .eqIfPresent(BizLicenceSafeMeasuresDO::getLicenceId, reqVO.getLicenceId())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getType, reqVO.getType())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getContent, reqVO.getContent())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getQualified, reqVO.getQualified())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getApplicable, reqVO.getApplicable())
                .eqIfPresent(BizLicenceSafeMeasuresDO::getPhoto, reqVO.getPhoto())
                .betweenIfPresent(BizLicenceSafeMeasuresDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(BizLicenceSafeMeasuresDO::getId));
    }

    default List<BizLicenceSafeMeasuresDO> selectListInLicenceIds(List<String> licenceIds){
        return selectList(new LambdaQueryWrapperX<BizLicenceSafeMeasuresDO>()
                .in(BizLicenceSafeMeasuresDO::getLicenceId,licenceIds));
    }

}
